package top.huhuiyu.springboot2.study.entity;

import lombok.Data;
import top.huhuiyu.springboot2.study.validate.CommonValidate;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * @author 胡辉煜
 */
@Data
public class TestEntity implements Serializable {
  private static final long serialVersionUID = 1L;
  @NotBlank(message = "姓名不能为空", groups = {CommonValidate.Add.class, CommonValidate.Update.class})
  @Pattern(regexp = CommonValidate.USERNAME, message = "姓名必须是4-16位的字母和数字以及_的组合，且必须是字母开头", groups = {CommonValidate.Add.class, CommonValidate.Update.class})

  private String name;
  @NotNull(message = "年龄不能为空", groups = {CommonValidate.Add.class, CommonValidate.Update.class})
  @Min(value = 1, message = "年龄不能低于1", groups = {CommonValidate.Add.class, CommonValidate.Update.class})
  @Max(value = 200, message = "年龄不能大于200", groups = {CommonValidate.Add.class, CommonValidate.Update.class})
  private Integer age;
  @NotNull(message = "id不能为空", groups = {CommonValidate.Update.class})
  private Integer id;
}
